public class Strings
{
   /**
      Gets the middle character or character pair from this string 
      when possible.
      @param str a string
      @return the middle character (if the string length is odd) or
      the middle two characters (if it is even), or the empty string if str is
      empty.
   */
   public static String getMiddle(String str)
   {
 int s=str.length();
      int mid=s/2;
      String m="";
      if(s>0){
         if(s%2==0){
            char m1,m2;
            m1=str.charAt(mid);
            m2=str.charAt(mid-1);
            m=m+m2+m1;
         }else{
            char m1;
            m1=str.charAt(mid);
            m=m+m1;
         }
      }else{
         m="";
      }
      return m;
  }
}